package mouse_rolloverAndMouse_over
{
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;

	public class RollOver extends Sprite
	{
		private var father:Sprite;
		private var child:Sprite;
		private var mouseOverNum:int = 0;
		private var mouseRollOverNum:int = 0;
		
		public function RollOver()
		{
			father = new Sprite();
			father.graphics.beginFill(0x773311);
			father.graphics.drawRect(100, 100, 200, 200);
			father.graphics.endFill();
			addChild(father);
			
			child = new Sprite();
			child.graphics.beginFill(0x11aacc);
			child.graphics.drawRect(150,150, 100, 100);
			child.graphics.endFill();
			father.addChild(child);
			
			father.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			father.addEventListener(MouseEvent.ROLL_OVER, onMouseRollOver);
		}
		
		private function onMouseOver(evt:MouseEvent):void
		{
			mouseOverNum++;
			var tf:TextField = new TextField();
			tf.text = "mouse_over" + mouseOverNum.toString();
			addChild(tf);
			tf.x = 300;
			tf.y = mouseOverNum * 20;
		}
		
		private function onMouseRollOver(evt:MouseEvent):void
		{
			mouseRollOverNum++;
			var tf:TextField = new TextField();
			tf.text = "roll_over" + mouseRollOverNum.toString();
			addChild(tf);
			tf.x = 400;
			tf.y = mouseRollOverNum * 20;
		}
	}
}